﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.MODEL.FoundationModel;
using MINERP.BLL.ComplexOrder;

namespace MINERP.ComplexOrder.Frms
{
    public partial class FrmYijian : Form
    {
        public FrmYijian()
        {
            InitializeComponent();
        }

        private void FrmYijian_FormClosing(object sender, FormClosingEventArgs e)
        {
           
            
        }
        public List<ComplexOrderInfo> CurrList = new List<ComplexOrderInfo>();
        public  ComplexOrderBll _bLL;
        public int userid;
        public int techid;
        private void FrmYijian_Load(object sender, EventArgs e)
        {
            labelNum.Text = CurrList.Count().ToString();
            ComplexOrderInfo first = CurrList.OrderBy(p => p.OrderProductId).FirstOrDefault();
            labelProduct.Text = first.ShopName+" "+first.CtmName+" "+first.OrderProductName;
            progressBar1.Minimum = 0;
            progressBar1.Maximum = CurrList.Count();
        }
        bool _run = false;
        int icount = 0;
        private void buttonStart_Click(object sender, EventArgs e)
        {
            
            foreach (ComplexOrderInfo curr in CurrList)
            {
                if (_run)
                {
                    icount++;
                    progressBar1.Value = icount;
                    labelProduct.Text = curr.ShopName + " " + curr.CtmName + " " + curr.OrderProductName;
                    bool boSuccess=_bLL.MakeSureProduct(curr, techid, userid);
                   
                }
            }
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            _run = false;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            _run = false;
            this.Close();
        }
    }
}
